import React from 'react';
import { Card } from 'antd';
import PropTypes from 'prop-types';
import { connect } from 'dva';
class My extends React.Component {
    constructor(props) {
        super(props);
        
    };
    initState = {};
    componentDidMount() {
        this.initState = window.__INITIAL_STATE__;
        if (!this.initState.islogin) {
            this.props.dispatch({ type: 'user/go', payload: { url: '/user' } });
        }
        this.setState({ nickName: this.initState.userinfo.nickName });
    };
    state = {
        nickName: '未登录！'
    }
    render() {
        return (
            <Card>
                我的名字是：{this.state.nickName}
            </Card>
        )
    }
}
My.propTypes = {
    dispatch: PropTypes.func
}
export default connect(({ user }) => ({  user }))(My);